1 Introduction

The market need for cooperative robots is rapidly increasing due to its ability to reduce the risk of injury and allowing safe interaction with human [1, 2]. The coexistence and interaction of human in the robot workspace are not suitable in many of the existing robotics applications, particularly the robot manipulators for several reasons. One of the most significant reasons is the safety factor [3,4,5,6].

Therefore, topics such as collision avoidance and collision detection are getting attention from researchers in robotics field. The collision detection is different from collision avoidance, where collision avoidance refers to algorithms that move the robot into configurations that avoid collisions. Obstacles are known or detected before contact is made between the robot and the object (or the robot itself). Collision avoidance is a preventative technique. Collision avoidance methods generally use vision or models of the robot and the environment to identify when the robot’s proposed motion will lead to a collision [7,8,9], while collision detection refers specifically to methods that recognize when a collision has occurred, which is the focus of this work. However, conventional robots technologies are far from responding to this need.

In order for the robots to be capable to interact and collaborate with humans, it should consider certain requirements in the mechanical structure design, its hardware, and the control schemes [10]. These robots typically require lightweight, compliant, and flexible mechanical structures. To achieve the flexibility and compliance requirements, some researchers proposed utilizing special actuators [11], e.g., the variable impedance actuators (VIA), series-elastic actuators (SEAs), and variable-stiffness actuators (VSAs) [12,13,14]. However, the most commonly used device to achieve joint compliance and flexibility is the harmonic drive. The harmonic drive is a flexible transmission that produces stiffness behavior, as a spring, between the motor and the link. It is widely used in serial manipulators due to negligible backlash, compact design, and a high torque-to-weight ratio, in addition to its ability to achieve the desired flexibility in robot joints [15]. Moreover, for the robot to be able to collaborate with humans physically there should be a certain control strategy to detect the physical collisions and interactions [16, 17]. In this direction, there are several methods used for determining these actions. The most effective, fast, and simplest method of detecting the collision is by adding external sensors such as using force sensors, accelerometers, and tactile sensors [18,19,20,21,22,23,24]. Although this method can detect the collision force accurately, it can just detect the collision where the sensor is located; moreover, it is an expensive solution. In order to cope with the problems of utilizing external sensors, there are other collision/interaction detection techniques without using external sensors (sensor-less) proposed in the literature [25,26,27,28,29,30]. These methods are able to extract more information from a physical collision and efficiently estimate the actual joints torque due to collision, but it required reliable information on full dynamic model, or at least the gravity model as in [31, 32], which might not be available for many of the industrial robots. There are several efficient methods proposed for collision detection in [33] with using torque sensors, and without such as the classical approach. The sensor-less classical approach for collision detection based on recognizing abnormal variations of the joints motors current is treated as actuation faults [34]. This method does not require information about the dynamic model; it requires setting a threshold value for the change in torque/current. This method is simple to be implemented in real time. The threshold value can influence the sensitivity of the collision detection. For instance, if a low threshold is chosen, then false signals for collision could be detected due to a rapid change in the trajectory speed and/or acceleration. On the other side, collision might not be detected in case of choosing high threshold value.

In this work, we decided to improve this simple method by making the threshold adaptive to the change in the speed and acceleration using the fuzzy logic control. The fuzzy system is built based on our knowledge from observing the robot’s readings during operation. The UR3 robot, which is used in this work, is one of the popular human collaborative robots in the market [35]. A review for the robot design and its forward and inverse kinematics analysis are presented in [36, 37]. The robot has a TCP/IP interface that allows access to some readings in real time such as joints actual position, actual speed, and actual current. In this work, the actual current readings during the trajectory at the different speeds and accelerations are used.

We carried out extensive series of experiments by exciting several trajectories, with different speeds and acceleration, and recorded these data. We found from experiments that the current change rate (\(\Delta i = i_{t} - i_{t - 1}\)), where \(t\) is the sample number, is usually smooth. This rate in normal operation, without collision, varies relatively to the change in velocity and acceleration, while during collision the current change rate (\(\Delta i\)) shows abnormal variation. Thus, a fuzzy control is designed for estimating the threshold value, as an output, using the speed and acceleration as inputs. The membership functions for the inputs and the output are based on the information acquired by experiments. By implementing the fuzzy controller, the threshold became more adaptive and it prevents false collision signals.

This paper is arranged as follows; Sect. 2 explains the methodology for collision detection. Section 3 presents the experimental setup including the implementation steps. Section 4 shows the results and provides relevant discussion. Finally, in Sect. 5 a conclusion is given.

2 Methodology

The method utilized in this work for detecting collision is based on observing the joints current change rate (\(\Delta i = i_{t} - i_{t - 1}\)), where in normal operation, without collision, the absolute value (\(\left| {\Delta i} \right|\)) should not exceed the threshold \(\varepsilon_{\text{th}}\). Once \(( \left| {\Delta i} \right| > \varepsilon_{\text{th}}\)) for any of the joints, this means that collision had occurred, and for an elementary safety reaction the robot should stop. The excessive value of (\(\left| {\Delta i} \right|\)) above \(\varepsilon_{\text{th}}\) in case of collision is due to the torques/moments produced at the joints from the collision force. An illustrated example is shown in Fig. 1. In Fig. 1a, the force is applied on link 2 and it is perpendicular to the axes of rotation of joint1, hence the highest moment/torque is produced in joint 1. In Fig. 1b, the force is applied on link 3 and it is perpendicular to the axes of rotation of joints 2 and 3, hence the moments/torques produced in these joints are higher than those of the other joints. We used this information for detecting collision. Experiments were carried out by running a trajectory two times: first without applying any external collision force and the second with applying external collision force. The sequence of photographs in Figs. 2 and 3 demonstrates the experiment, where Fig. 2 is taken while the trajectory is running without collision force, and Fig. 3 is taken under collision force.

Fig. 1
figure 1

Collision force produces moments at the joints in two different examples (a) and (b)

Fig. 2
figure 2

Experiment demonstration without collision force

Fig. 3
figure 3

Experiment demonstration under collision force

Figure 4a shows the joints positions in time during the trajectory. In Fig. 4b–d, the joints readings of the current (i) and the current change (|\(\Delta i\)|) during the trajectory are shown, where the plot in red is the reading of the data during applying external collision forces, and the plot in blue is the reading of the data without applying any external forces; in this figure, the first three joints readings are presented. It is clearly obvious from the figure that collision forces induce excessive currents in joints and appear as spikes.

Fig. 4
figure 4

a Joints positions for the excited trajectory over time; bd the joints current readings (\(i\)) and the current change (\(\Delta i\)) during the trajectory; first with applying collision “in red” and second without collision “in blue”

So the method mainly depends on setting threshold value \(\varepsilon_{\text{th}}\) that could detect the excessive current change (|\(\Delta i\)|) such that it could detect false signals in case of choosing low \(\varepsilon_{\text{th}}\), or it might not be able to detect the collision if high value is chosen. For these reasons, we carried out extensive series of experiments by performing several trajectories with different speeds and acceleration to get an approximate estimation of (\(\Delta i\)). This information is used to build the fuzzy controller, such that by giving the value of the speed and acceleration we get the proper \(\varepsilon_{\text{th}}\). The proposed collision detection algorithm is shown in Fig. 5.

Fig. 5
figure 5

Collision detection algorithm

2.1 Fuzzy logic control

Fuzzy control provides a formal methodology for representing, manipulating, and implementing a human’s heuristic knowledge about how to control a system [38]. It came out for reasons to cope with the disadvantages of conventional control, whereas most conventional techniques require either an analytical model or an experimental model. Fuzzy logic control is particularly suitable for complex and ill-defined processes. The fuzzy controller has four main components: (1) The “rule-base” holds the knowledge, in the form of a set of rules, of how to control the system. (2) The inference mechanism evaluates which control rules are relevant at the current time and then decides what the input to the plant should be. (3) The fuzzification interface simply modifies the inputs so that they can be interpreted and compared to the rules in the rule-base. And (4) the defuzzification interface converts the conclusions reached by the inference mechanism into the inputs to the plant. The fuzzy controller components are shown in Fig. 6, where the joint speed (\(\dot{q}\)) and acceleration (\(\ddot{q}\)) represent the inputs, and the threshold \(\varepsilon_{\text{th}}\) represents the output. The next section shows the implementation steps.

Fig. 6
figure 6

Fuzzy control architecture

3 Experimental setup

The first step is performing several trajectories with different speeds (\(\dot{q}\)) and acceleration (\(\ddot{q}\)), and recording these data in real time. From these data, we determined the maximum reading of (\(\Delta i\)) for every different pair of speed and acceleration. The maximum value of (\(\Delta i\)) is set to be the reference value for the threshold \(\varepsilon_{\text{th}}\). In fact the relation between (\(\Delta i\)) to the change in \(\dot{q},\ddot{q}\) is very noisy, and we cannot build \(\varepsilon_{\text{th}}\) estimation on a filtered signal. So we took the highest value of (\(\Delta i\)) within a range for several trajectories. For instance, we defined a membership function (MF) for the speed calling it “low,” and similarly for the acceleration. The low MF of the speed takes absolute values from 0 to 0.15 rad/s as 100% low, and the acceleration takes values from 0 to 0.2 rad/s2 as 100% low. Within the range of low speed and low acceleration, we get the highest value for \(\Delta i\) in all the experiments and set it as the reference for collision threshold. Based on this idea, we designed the fuzzy controller for each joint. In this paper, the steps for joint1 only are shown, as it can be implemented in the same way for the rest joints.

3.1 Implementation steps

The implementation steps are described as follows;

  1. (a)

    Examine all the recorded trajectories data Determine the relation between speed, acceleration, and (\(\Delta i\)). Then the highest value for (\(\Delta i\)) among the different classes of \(\dot{q}\) and \(\ddot{q}\) is identified. This step is shown in Fig. 7, where the red circles show the maximum value within the specified ranges of the speed and acceleration.

    Fig. 7
    figure 7

    Relation between speed (\(\left| {\dot{q}} \right|\)), acceleration (\(\left| {\ddot{q}} \right|\)), and (Δi)

  2. (b)

    Classify the speed and acceleration as follows The speed has 4 classes {low, medium, high, very high}, and the acceleration has 5 classes {low, medium, high, very high, extremely high}, the ranges for each class are shown in

  3. (c)

    Table 1. The classification was decided based on our experience, such that the ranges considered high, low, or medium are determined according to our application requirements.

    Table 1 Speed and acceleration classifications
  4. (d)

    Fuzzyfication Is the process that converts or transforms the measured inputs called crisp values, into the fuzzy linguistic values used by the fuzzy interference mechanism. The inputs MF functions are shown in Fig. 8; Fig. 8a shows the speed and (b) shows the acceleration.

    Fig. 8
    figure 8

    The fuzzy system; a and b are the input membership functions for speed and acceleration, c is the output membership function collision threshold, and d rule-base

  5. (e)

    Define the output membership function Designed based on the maximum (\(\Delta i\)), where it is set to be bit higher than the maximum (\(\Delta i\)) for the different speeds and accelerations ranges. The output MF for the collision threshold \(\varepsilon_{\text{th}}\) is shown in Fig. 8c.

  6. (f)

    Set the Rule-base A collection of the expert control rules (knowledge) needed to achieve the control goal, as shown in Fig. 8d

  7. (g)

    Defuzzyfication Is the process that converts the result of fuzzy interference mechanism into the required crisp value. The correlation-minimum inference method proposed by Mamdani [39] is applied for fuzzy inference mechanism, and the center of area method [40] is used to estimate the value of \(\varepsilon_{\text{th}}\). The surface view for the whole fuzzy system is shown in Fig. 9.

    Fig. 9
    figure 9

    Surface view for the collision threshold estimation fuzzy controller

The next section provides the results and some discussion related to the system implementation.

4 Results and discussion

The relation in Fig. 7, for more than 50,000 observations, shows that the values (\(\Delta i\)) are not smooth and contain noise, and we could not easily get a linear relation for the change in \(\dot{q}\) and \(\ddot{q}\). And the maximum values in red are more probably noisy readings. Due to this, we could not build the estimation of collision threshold on the majority of (\(\Delta i\)) readings, which are shown as a bulk in the blue color. Instead we took the maximum noisy data. Therefore, an extensive large number of experiments observations is required, as to get the maximum possible value for (\(\Delta i\)) within a specified range of \(\dot{q}\) and \(\ddot{q}\), so that in normal operation under any noisy circumstances, without collision, the value (\(\Delta i\)) should not exceed the collision threshold \(\varepsilon_{\text{th}}\). And this will ensure that if the value of (\(\Delta i\)) exceeds the \(\varepsilon_{\text{th}}\), it means that collision had occurred.

The surface view of the system in Fig. 9 shows the resulting threshold relative to the different ranges of \(\dot{q}\) and \(\ddot{q}\), which ensures the value of \(\varepsilon_{\text{th}}\) adaptive to the change in \(\dot{q}\) and \(\ddot{q}\); moreover, it shows that the value of \(\varepsilon_{\text{th}}\) at collision will never be below the value of (\(\Delta i\)) within the same range of \(\dot{q}\) and \(\ddot{q}\) in normal operation. For instance, if we examine the observation with black cross mark shown in Fig. 7 at acceleration about 2.8642 (rad/s2) and the speed about 0.8166 (rad/s2), we can find that (\(\Delta i\)) is about 0.3185. And by using the same values of \(\dot{q}\) and \(\ddot{q}\) to check the fuzzy system output, from the surface view in Fig. 9 as a red cross mark, it can be found that the collision threshold \(\varepsilon_{\text{th}}\) is about 0.7–0.8, which is obviously higher than (\(\Delta i = 0.3185\)) the value at normal operation. This means that the fuzzy system adjusted the threshold \(\varepsilon_{\text{th}}\) to a value higher than the measured \(\Delta i\) at the same speed and acceleration.

The output value from the fuzzy system \(\varepsilon_{\text{th}}\) represents the sensitivity of the robot in detecting collision, and we are satisfied with this sensitivity level. However, we can change the collision sensitivity by doing some manual adjustments to the input and output membership functions values of the fuzzy system to get different collision thresholds \(\varepsilon_{\text{th}}\).

Finally, this system is implemented in real time by developing a python program on a PC connected to the robot through the TCP/IP interface. The python language has several useful modules that can be used in robotics applications, such as the SciKit-Fuzzy toolbox for SciPy module [41], which can be used for implementing the fuzzy system.

5 Conclusion

In this paper, we showed a modified way for detecting collision within the robot manipulator by developing a fuzzy system. The proposed method is based on detecting the variation and setting a threshold value above this value meaning that the collision had occurred. From the recorded data results of the different trajectories, we showed the behavior of at the different ranges of \(\dot{q}\) and \(\ddot{q}\). Then we showed the implementation steps to obtain an adaptive threshold value using the fuzzy logic system. As a result, this paper contributes in achieving the collision detection with high performance by overcoming the false signal detection which might occur due to using fixed threshold values in the classical method.